package com.jbm.enterapplication.set

import android.content.Intent
import android.view.View
import com.jbm.enterapplication.R
import com.jbm.enterapplication.activity.MainActivity
import com.jbm.enterapplication.moduserpwd.view.ChangPwd
import com.jbm.enterapplication.sharedprefer.SharedPreActivity
import com.jbm.enterapplication.utlisclass.Constant
import com.jbm.enterapplication.utlisclass.ExitActivity
import com.jbm.enterapplication.view.DoubleButtonDialog
import kotlinx.android.synthetic.main.activity_user_set.*
import kotlinx.android.synthetic.main.lz_titlehurdle.*

class UserSet : MainActivity(), View.OnClickListener {
    override fun onClick(v: View?) {
        when(v?.id){
            R.id.xiugaimima->{
                startActivity(Intent(this@UserSet, ChangPwd::class.java))
            }
            R.id.tuichu->{
                setExitUser("您是否要退出当前用户")
            }
            R.id.teleft->{
                finish()
            }
        }
    }

    override fun getinit() {
        ExitActivity.getInstanst().addActivity(this)
        shandprefter= SharedPreActivity(this)
        xiugaimima.setOnClickListener(this)
        tuichu.setOnClickListener(this)
        teleft.setOnClickListener(this)
        tetitle.text="设置"
    }

    override fun getView(): Int {
        return R.layout.activity_user_set
    }
    var shandprefter: SharedPreActivity?=null
    //一些提示的时候调用
    fun setExitUser(name: String) {

        val dialog = DoubleButtonDialog(this@UserSet, name)
        dialog.getokbtn().setOnClickListener {
            shandprefter?.ExitUser()
            ExitActivity.getInstanst().exitActivity()
//            startActivity(Intent(this@OpenDoor,UserLogin ::class.java))
            Constant.isWXLogin=false
            dialog.dismiss()
        }
//        dialog.setisVisibility()
        dialog.getnobtn().setOnClickListener({
            dialog.dismiss()
        })

    }
}
